﻿
using System;
using System.Collections.Generic;
using System.Text;

using YouHP.Utility;
using YouHP.BLL;
using YouHP.Model;

namespace YouHP.Pages.TreatmentHistory
{
    public class Index2 : YouHP.Pages.PatientBasePage
    {
        private const int TreatmentBaseHeight = 110;
        private const int TreatmentYGap = 30;
        protected int TreatmentGraphHeight = TreatmentBaseHeight + TreatmentYGap;

        protected int diseaseId = -1;

        protected override void ShowPage()
        {
            base.ShowPage();
            if (ErrorCount > 0) return;

            HandleCommon();
            if (ErrorCount > 0) return;

            if (IsPost) HandlePost();
            else HandleGet();
        }

        protected List<TreatmentHistoryInfo> UsingTreatmentList;
        protected List<TreatmentHistoryInfo> StoppedTreatmentList;

        protected new void HandleCommon()
        {
            this.AddLocation("治疗记录", "/TreatmentHistory/Index.aspx");
            this.SetTitle("治疗记录");
        }

        protected new void HandlePost()
        {

        }

        protected new void HandleGet()
        {
#if GENDATA
            UsingTreatmentList = new List<TreatmentHistoryInfo>();
            for (int i = 0; i < 5; i++)
            {
                TreatmentHistoryInfo info = new TreatmentHistoryInfo();
                info.Id = i;
                info.TreatmentName = "治疗" + i;
                info.TreatmentId = 15;
                info.DataValue = 15;
                info.Unit = "毫克";
                info.UsePurpose = i % 4;
                info.StartDate = Convert.ToDateTime("2008-05-01");
                UsingTreatmentList.Add(info);
            }
            StoppedTreatmentList = new List<TreatmentHistoryInfo>();
            for (int i = 0; i < 5; i++)
            {
                TreatmentHistoryInfo info = new TreatmentHistoryInfo();
                info.Id = i;
                info.TreatmentName = "治疗" + i;
                info.TreatmentId = 15;
                info.DataValue = 15;
                info.Unit = "毫克";
                info.UsePurpose = i % 4;
                info.StartDate = Convert.ToDateTime("2007-06-03");
                StoppedTreatmentList.Add(info);
            }
#else
            UsingTreatmentList = PatientTreatmentBLL.Instance.GetAllCurUsedTreatments(PrData.Id);
            StoppedTreatmentList = PatientTreatmentBLL.Instance.GetAllCurNoUsedTreatments(PrData.Id);
#endif

            //利用治疗个数来计算flash高度
            List<TreatmentHistoryInfo> CurrentTreatmentList = PatientTreatmentBLL.Instance.GetAllCurTreatments(PrData.Id);
            if (CurrentTreatmentList != null)
            {
                TreatmentGraphHeight += (CurrentTreatmentList.Count) * TreatmentYGap;
            }

            if (UserData == null || UserData.Id <= 0)
            {
                diseaseId = 1;
            }
            else
            {
                PatientRecordInfo prInfo = PatientBLL.Instance.GetPatientRecordInfo(UserData.Id);
                if (prInfo == null || prInfo.DiseaseId <= 0)
                {
                    diseaseId = 1;
                }
                else
                {
                    diseaseId = prInfo.DiseaseId;
                }
            }
           
        }


    }
}